package file;

import java.io.File;
import java.io.FileFilter;

/**
 * 获取当前目录中名字里含有t的子项
 */
public class Test {
    public static void main(String[] args) {
        File dir = new File(".");
        if(dir.isDirectory()){
            FileFilter fileFilter = new FileFilter() {
                public boolean accept(File file) {
                    String name = file.getName();
//                    return name.indexOf("t")>=0;
                    return name.contains("t");
                }
            };
            File[] subs = dir.listFiles(fileFilter);
            System.out.println(subs.length);
        }

    }
}
